package service

import (
	"github.com/dchest/captcha"
	"github.com/gin-gonic/gin"
)

type GraphiCaptcha struct {
	Base
}

func (s GraphiCaptcha) Create(c *gin.Context) map[string]string {

	captchaId := captcha.NewLen(4)
	capt := make(map[string]string)
	capt["code_id"] = captchaId
	capt["path"] = "/share/captcha/" + captchaId + ".png"
	return capt
}

func (s GraphiCaptcha) Verify(captchaId string, val string, c *gin.Context) bool {
	return captcha.VerifyString(captchaId, val)
}
